package cdu.hjx.project.sys.service.impl;

import cdu.hjx.project.pojo.DictDetail;
import cdu.hjx.project.sys.mapper.DictDetailMapper;
import cdu.hjx.project.sys.service.DictDetailSerivce;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DictDetailServiceImpl implements DictDetailSerivce {

    @Resource
    private DictDetailMapper dictDetailMapper;
    @Override
    public int addDictDetail(DictDetail dictDetail) throws Exception {
        return dictDetailMapper.addDictDetail(dictDetail);
    }

    @Override
    public DictDetail findDictDetail(String dtype, String dtag) throws Exception {
        return dictDetailMapper.findDictDetail(dtype, dtag);
    }

    @Override
    public int insertDictDetail(DictDetail dictDetail) throws Exception {
        DictDetail detail = findDictDetail(dictDetail.getDtype(), dictDetail.getDtag());
        return null == detail ? addDictDetail(dictDetail) : 0;
    }

    @Override
    public List<DictDetail> findDictDetailByType(String dtype) throws Exception {
        return dictDetailMapper.findDictDetailByType(dtype);
    }
}
